﻿function  add(num1,num2){
    return num1 + num2;
}


function addRandom(num){
    return num+ Math.random();
}

function createTaxCalculator(tax){
    function calculateTax(amount){
        return amount * tax;
    }
    return calculateTax;
}

const calculateVatAmount = createTaxCalculator(0.19);
const incomeTaxAmount = createTaxCalculator(1.19);
console.log(incomeTaxAmount(200));

const mySelf= {
    name:'Max',
    friends:[{
        name:'Holmes',
        friends:[{
            name:'Lucy',
            friends:[{
                name:'lilei',
            },{
                name:'million',
            }]

        }]
    },{
        name:'Lily',
    }]
};

function printFriendName(person){
    const collectedNames =[];
    if(!person.friends){
        return [];
    }
    for(const friend of person.friends){
        collectedNames.push(friend.name);
        collectedNames.push(...printFriendName(friend));
    }
    return collectedNames;
}

console.log(printFriendName(mySelf));



